<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<meta name="viewport" content="width=1000, initial-scale=1.0, maximum-scale=1.0">
	    <!-- Loading Bootstrap -->
	    <link href="./Public/Admin/Flat/dist/css/vendor/bootstrap.min.css" rel="stylesheet">
	    <!-- Loading Flat UI -->
	    <link href="./Public/Admin/Flat/dist/css/flat-ui.css" rel="stylesheet">
	    <link rel="shortcut icon" href="./Public/Admin/Flat/img/favicon.ico">
	    <script src="./Public/jquery-1.12.2.min.js"></script>
	    <!-- HTML5 shim, for IE6-8 support of HTML5 elements. All other JS at the end of file. -->
	    <!--[if lt IE 9]>
	      <script src="dist/js/vendor/html5shiv.js"></script>
	      <script src="dist/js/vendor/respond.min.js"></script>
	    <![endif]-->
	    <style type="text/css">
	    	tr{
	    		font-size: 14px;
	    	}
	    	p{
	    		font-size: 14px;
	    	}
	    </style>
	    <!--<script>
	    	$(function(){
	    		var arr = [];
	    		var sel = $('select[name="spec[]"]')
	    		var len = sel.length
	    		for (var i = 0; i < len; ++i){
					arr[i] = sel.eq(i).val();
				}
				var a = arr.join(',')
				//声明空数组 用于接收选中的option的gaid
	    		var data = [];
	    		//select改变的时候触发的事件
	    		$('.spechange').change(function(){
	    			//给每一个select绑定事件
	    			$('.spechange').each(function(){
	    				//获得选中的option的value值 即gaid
		    			var combine = $(this).children('option:selected').attr('value')
		    			//把获得的gaid压进arr数组
		    			data.push(combine)
	    			})
	    			var b = data.join(',')
	    			if(a == b){
	    				data = []
	    				return
	    			}
//	    			发送ajax
	    			$.ajax({
	    				//提交的方式为post
	    				type:"post",
	    				//发送地址
	    				url:"<?php echo U('checkgl')?>",
	    				//发送的数组
	    				data:{combine:data,gid:<?php echo $_GET['gid']?>},
	    				//对返回的数据进行判断
	    				success:function(phpData){
	    					//如果返回1  则代表货品列表中已有选中的货品组合
	    					if(phpData == 1){
	    						//弹出提示消息
	    						alert("货品组合已存在，如果要修改库存，请点击编辑")
	    						//把arr数组清空 不然会一直累加
	    						data = []
	    						//把option弹回请选择 让用户重新选中货品组合
	    						$('.emptyspec').each(function(){
	    							$(this).attr({selected:'selected' });
	    						})
	    					}else {
	    						//反之 则货品列表中没有选中的组合 用户可以选择 同时也把数组清空；
	    						data = []
	    					}
	    				}
	    			});
	    		})
				

	    	})
	    </script>-->
	</head>
	<body>
		<form action="" method="post">
			<table class="table table-hover">
				<tr class="active">
				  <th width="150">货品ID</th>
				  <?php foreach ($data as $v){?>
				  <th width="250"><?php echo $v['taname']?></th>
				  <?php }?>
				  <th width="250">库存</th>
				  <th width="250">货号</th>
				  <th width="250"></th>
				</tr>
				<tr>
					<td><?php echo $oldData['glid']?></td>
					<?php foreach ($data as $v){?>
					<td>
						<select class="form-control" width="150px" name="spec[]" >
							<?php foreach ($v['son'] as $vv){?>
							<option value="<?php echo $vv['gaid']?>" <?php if(in_array($vv['gaid'],$checkData)){?>
                selected="selected"
               <?php }?>><?php echo $vv['gavalue']?></option>
							<?php }?>
						</select>
					</td>
					<?php }?>
					<td>
						<input type="text" class="form-control" id="exampleInputName2" name="inventory" value="<?php echo $oldData['inventory']?>">
					</td>
					<td>
						<input type="text" class="form-control" id="exampleInputName2" name="number" value="<?php echo $oldData['number']?>">
					</td>
					<td>
						<button class="btn btn-danger btn-lg" type="submit">修改</button>
					</td>
				</tr>
			</table>
			<input type="hidden" name="goods_gid"  value="<?php echo $oldData['goods_gid']?>" />
			<input type="hidden" name="glid"  value="<?php echo $_GET['glid']?>" />
		</form>
	</body>
</html>
